#/bin/bash
DIR=$(cd "$(dirname "$0")" && cd .. && pwd)
echo "进入项目目录"
echo $DIR

if [ "$1" == "start" ];then
  echo "执行运行命令"
  # python环境需根据部署情况另执行，这里默认使用venv中的环境
  uv run python run.py send > /root/logs/send.log 2>&1 &
  uv run python run.py recv > /root/logs/recv.log 2>&1 &
  tail -f /root/logs/*.log
  wait
elif [ "$1" == "stop" ];then
  echo "执行关闭命令"
  PROCESS=`ps -ef | grep run.py | grep -v grep | awk '{print $2}'`
  echo "查找正在运行的服务"
  for i in $PROCESS
  do
    kill -9 $i
    echo "杀掉运行的服务"
  done
else
  echo "请检查命令参数（start or stop）"
Fi
